This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
token-2022: Add scaled amount extension #7511
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Problem The interest-bearing extension is useful for tokens that accrue in value constantly, but many "rebasing" tokens on other blockchains employ a different method of updating the number of tokens in accounts. Rather than setting a rate and allowing the number to change automatically over time, they set a scaling factor for the tokens by hand. #### Summary of changes Add a new `ScaledUiAmount` extension to token-2022 for doing just that. This is essentially a simplified version of the interest-bearing extension, where someone just sets a scaling value into the mint directly. The scale has no impact on the operation of the token, just on the output of `amount_to_ui_amount` and `ui_amount_to_amount`.
I got feedback that issuers want to be able to set the multiplier in the future, so I'll implement that and then re-open this PR |
Ok, this should be ready for another look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good to me! Just minor questions and comments regarding the docs and tests.
token/program-2022/src/extension/scaled_ui_amount/instruction.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: samkim-crypto <[email protected]>
This should be ready for another look |
samkim-crypto
approved these changes
Nov 25, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Everything looks find to me!
This was referenced Nov 25, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The interest-bearing extension is useful for tokens that accrue in value constantly, but many "rebasing" tokens on other blockchains employ a different method of updating the number of tokens in accounts.
Rather than setting a rate and allowing the number to change automatically over time, they set a scaling factor for the tokens by hand.
Summary of changes
Add a new
ScaledUiAmount
extension to token-2022 for doing just that. This is essentially a simplified version of the interest-bearing extension, where someone just sets a scaling value into the mint directly. The scale has no impact on the operation of the token, just on the output ofamount_to_ui_amount
andui_amount_to_amount
.cc @jnwng